<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>d3基础语法</title>
    <script src="./js/d3.v3.min.js"></script>
    <script>
        window.onload = () => {
            // 在body里边添加p标签  文字是北京
            // d3.select("body").append("p").text("北京");
            // d3.select("body").append("p").text(() => {
            //     return "北京";
            // });

            const arr = ["北京","上海","广州","深圳"];
            // d3.select("body").selectAll("p").data(arr).text((item, index) => {
            //     return item;
            // });

            const body  = d3.select("body");
            body.selectAll("p").data(arr).text(item => {
                return item;
            });
        }
    </script>
</head>
<body>
    <p></p>
    <p></p>
    <p></p>
    <p></p>
</body>
</html> 